using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace PRXVerifier
{
    public static class NativeMethods
    {
        [DllImport("WMVCore.dll", EntryPoint = "WMCreateProfileManager", SetLastError = true,
            CharSet = CharSet.Unicode, ExactSpelling = true,
             CallingConvention = CallingConvention.StdCall)]
        public static extern uint WMCreateProfileManager(
            [Out, MarshalAs(UnmanagedType.Interface)]	out IWMProfileManager ppProfileManager);

        [DllImport("WMVCore.dll", EntryPoint = "WMCreateSyncReader", SetLastError = true,
            CharSet = CharSet.Unicode, ExactSpelling = true,
             CallingConvention = CallingConvention.StdCall)]
        public static extern uint WMCreateSyncReader(
            [In, MarshalAs(UnmanagedType.IUnknown)] object pUnkReserved,
            [In] uint dwRights,
           [Out, MarshalAs(UnmanagedType.Interface)]	out IWMSyncReader ppReader);
    }

    [Guid("9397f121-7705-4dc9-b049-98b698188414"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IWMSyncReader
    {
        uint Open([In, MarshalAs(UnmanagedType.LPWStr)] string pwszFilename);
        uint Close();
        uint SetRange();
        uint SetRangeByFrame();
        uint GetNextSample();
        uint SetStreamsSelected();

        uint GetStreamSelected();

        uint SetReadStreamSamples();

        uint GetReadStreamSamples();
        uint GetOutputSetting();

        uint SetOutputSetting();

        uint GetOutputCount();

        uint GetOutputProps();

        uint SetOutputProps();

        uint GetOutputFormatCount();

        uint GetOutputFormat();

        uint GetOutputNumberForStream();

        uint GetStreamNumberForOutput();

        uint GetMaxOutputSampleSize();

        uint GetMaxStreamSampleSize();

        uint OpenStream();
    }

    public enum WMT_VERSION
    {
        WMT_VER_4_0 = 0x00040000,
        WMT_VER_7_0 = 0x00070000,
        WMT_VER_8_0 = 0x00080000,
        WMT_VER_9_0 = 0x00090000
    }

    [Guid("d16679f2-6ca0-472d-8d31-2f5d55aee155"),
    InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IWMProfileManager
    {
        //
        // Create a profile with nothing in it.
        //
        uint CreateEmptyProfile([In] WMT_VERSION dwVersion,
                                   [Out, MarshalAs(UnmanagedType.Interface)]out IWMProfile ppProfile);

        //
        // Load a system profile given its ID.
        //
        uint LoadProfileByID([In] Guid guidProfile,
                                [Out, MarshalAs(UnmanagedType.Interface)] out IWMProfile ppProfile);

        //
        // Load a profile from a stored string.
        //
        uint LoadProfileByData([In, MarshalAs(UnmanagedType.LPWStr)] string pwszProfile,
                                  [Out, MarshalAs(UnmanagedType.Interface)] out IWMProfile ppProfile);

        //
        // Save profile specified by its string.
        //
        uint SaveProfile([In, MarshalAs(UnmanagedType.Interface)] IWMProfile pIWMProfile,
                            StringBuilder pwszProfile,
                            [In, Out] ref uint pdwLength);

        //
        // Iterate through the system profiles.
        //
        uint GetSystemProfileCount([Out] out uint pcProfiles);

        uint LoadSystemProfile([In] uint dwProfileIndex,
                                  [Out, MarshalAs(UnmanagedType.Interface)] IWMProfile ppProfile);
    }

    [Guid("96406bdb-2b2b-11d3-b36b-00c04f6108ff"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IWMProfile
    {
    }
}
